package core.gui;

import core.input.Input;

import recorder.input.InputManagerRecorder;

import java.awt.Graphics2D;
import java.util.ArrayList;

public class GlassPane extends InputManagerRecorder{
	
	private Input input;
	
	ArrayList<Component> listComponent = new ArrayList<Component>();
	
	public GlassPane(Input input){
		this.input = input;
	}
	
	public boolean isOverGUI(int x, int y){
		for(int i=0; i<listComponent.size(); i++){
			if(listComponent.get(i).boundingRect.contains(x, y)){
				return true;
			}
		}
		return false;
	}
	
	public void reset(){
		listComponent.clear();
	}
	
	public void addComponent(Component c){
		listComponent.add(c);
		c.setInput(input);
		addInputReceiver(c);
	}
	
	public void draw(Graphics2D g){
		for(int i=0; i<listComponent.size(); i++){
			listComponent.get(i).render(g);
		}
	}
	
	public void update(int deltaTime){
		for(int i=0; i<listComponent.size(); i++){
			listComponent.get(i).update(deltaTime);
		}
	}

}
